#!/usr/bin/env php
<?php

# A worker that sends emails based on the workload passed to it.

$worker = new GearmanWorker();
$worker->addServer('127.0.0.1', 4730);
$worker->addFunction('send_email', 'send_email_callback');
while (@$worker->work());

function send_email_callback($job)
{
  $options = json_decode($job->workload(), true);
  mail($options['to'], $options['subject'], $options['body']);
}

?>
